<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ page import="org.lsms.dao.impl.*" %>
<%@ page import="org.lsms.bean.*"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    
    <title>Chair Decision Page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="LSMS,ICSEE,CHAIR">
	
	<link rel="stylesheet" type="text/css" href="../css/author_layout.css">
	<link rel="stylesheet" type="text/css" href="../css/hyper_link_style.css">

	<script type="text/javascript">
	
		function openpage(curpage){
			document.spage.page.value = curpage;
			document.spage.submit();
		}
	
		function select_all(){
			var a = document.paper.select_this_paper;
			var b = document.paper.select_all_paper;
			if(b.checked==true){
				for(var i=0;i<a.length;i++){
					a[i].checked = true;
				}
			}else{
				for(var j=0;j<a.length;j++){
					a[j].checked = false;
				}
			}
		}	
		
		function selectall()
		{
    	
    		var b = document.getElementsByName("select_all_paper");
   			if(b[0].checked==true){
   				var ass = document.getElementsByName("select_this_paper");
   				for (var i=0; i<ass.length; i++)
      				ass[i].checked = true;
   			}else{
   				var ass = document.getElementsByName("select_this_paper");
  		 		for (var i=0; i<ass.length; i++){
      			ass[i].checked = false;
   				}
			}
		}
		
		function pass(paper_id){
			var i = window.confirm("Are you sure you want to pass paper "+paper_id+"?");
			if(i){
				window.location="../pass_paper?paper_id="+paper_id;
			}else{
				return false;;
		}
		}
		
		function deny(paper_id){
			var i = window.confirm("Are you sure you want to deny paper "+paper_id+"?");
			if(i){
				window.location="../deny_paper?paper_id="+paper_id;
			}else{
			return false;
		}
		}
		
		function pass_selected(){
			var s = "";
			var i = 0;
			var length = document.paper.select_this_paper.length;
			for(i=0;i<length;i++)
			{
				if(document.paper.select_this_paper[i].checked==true)
				{
					s = s+document.paper.select_this_paper[i].value+",";
				}
			}
			if(s!=""){
				var a = window.confirm("Are you sure you want to pass paper "+s+"?");
				if(a){
					window.location="../pass_selected_paper?paper_id="+s;
				}else{
					return false;
				}
			}else{
				alert("No paper selected!");
				alert("Please select at least one paper!");
				return false;
			}
		}
		
		function deny_selected(){
			var s = "";
			var i = 0;
			var length = document.paper.select_this_paper.length;
			for(i=0;i<length;i++)
			{
				if(document.paper.select_this_paper[i].checked)
				{
					s = s+document.paper.select_this_paper[i].value+",";
				}
			}
			if(s!=""){
				var a = window.confirm("Are you sure you want to deny paper "+s+"?");
				if(a){
					window.location="../deny_selected_paper?paper_id="+s;
				}else{
					return false;
				}
			}else{
				alert("Please select at least one paper!");
				return false;
			}
		}
			
		
		
	</script>
	

	<style type="text/css">
	
		td{
			text-align:center;
		}
		
		#all_paper{
			font-size:xx-small;
		}
	</style>
	
	
  </head>
  
  <body>
	<div id="container">
		<div id="header" class="logo_image"></div>
		<div class="nav"></div>
		<div id="author_menu" class="border">
			<table border="0" width="100%"  >
				<tr>
					<td  bgcolor="#CCCCCC"><a href="../index.jsp">Home</a></td>
				</tr>
				<tr>
					<td  bgcolor="#CCCCCC"><a href="chair_decision.jsp">View All Papers/Decision</a></td>
				</tr>
				<tr>
				<%
					DaoImpl impl = new DaoImpl();
					HashMap<String,Integer> hm = impl.get_site_setting();
					int member_invite = hm.get("member_invite");
					if(member_invite==1){
				 %>
					<td  bgcolor="#CCCCCC"><a href="invite_member.jsp">Invite PC Member</a></td>
				<%
					}else{
				 %>
				 	<td  bgcolor="#CCCCCC"><a href="../error/invite_member_forbidden.jsp">Invite PC Member</a></td>	
				<%
					}
				 %>
				</tr>
				<tr>
					<td  bgcolor="#CCCCCC"><a href="member_conf.jsp">Pcmember Confirmation</a></td>
				</tr>
				<tr>
					<td  bgcolor="#CCCCCC"><a href="paper_assign.jsp">Paper Assign</a></td>
				</tr>
				<tr>
					<td  bgcolor="#CCCCCC"><a href="assign_index.jsp">Assign Papers' Indexes</a></td>
				</tr>
				<tr>
					<td  bgcolor="#CCCCCC"><a href="modify_info.jsp">Modify Information</a></td>
				</tr>
				<tr>
					<td  bgcolor="#CCCCCC"><a href="../logout">Log Out</a></td>
				</tr>
			</table>
		</div>
		
		<div id="content" class="bg_color border">
			<div style="margin:15px">
			<p><b>All Papers</b></p>
				<div id="all_paper" class="border">
				<form name="paper" onsubmit="show()">
				<table align="center" border="0" style="width:680px">
				<tr>
					<th>&nbsp;</th>
					<th>ID</th>
					<th>Topics</th>
					<th>Title</th>
					<th>Author</th>
					<th>Submit Date</th>
					<th>Paper Status</th>
					<th>Details</th>
					<th>&nbsp;</th>
				</tr>
				<tr>
					<td colspan="9">
					<hr>
					</td>
				</tr>
				<%
					int page_count = 1;
					int row = 5;
					int sum_page = 1;
					int sum_row = impl.get_num_of_all_paper();
					try{
						page_count = Integer.parseInt(request.getParameter("page"));
						sum_row = Integer.parseInt(request.getParameter("sum_row"));
					}catch(Exception e){}
					
					HashMap<String,List<Paper>> map = impl.get_all_paper(page_count,row);
					List<Paper> list = map.get("all");
					if(list.size()<1){
				 %>
				<tr>
					<td colspan="9">
					<p align="center">No Paper yet!</p>
					</td>
				</tr>
				<%
					}
					for(int i=0;i<list.size();i++){
						Paper paper = list.get(i);
						int paper_id = paper.getPaperid();
				%>
				<tr>
				 	<td>
				 	<input type="checkbox" name="select_this_paper" value="<%=paper_id%>">
				 	</td>
				 	<td style="width:5px">
				 	<%
				 		out.print(paper_id);
				 	 %>
				 	</td>
				 	<td style="width:3px">
				 	<%
				 		String topic1 = paper.getFirsttopic();
				 		String topic2 = paper.getSecondtopic();
				 		out.print(topic1+"&"+topic2);
				 	 %>
				 	</td>
				 	<td style="width:200px">
				 	<%
				 		out.print(paper.getPapertitle());
				 	 %>
				 	</td>
				 	<td style="width:20px">
				 	<%
				 		out.print(paper.getAuthorname());
				 	 %>
				 	</td>
				 	<td>
				 	<%
				 		out.print(paper.getPapersubmitdate());
				 	 %>
				 	</td>
				 	<td>
				 	<%
				 		int paper_status = paper.getPaperstatus();
				 		if(paper_status==0){
				 			out.print("<font color='yellow'>Not Decided<font>");
				 	 	}else if(paper_status==1){
				 	 		out.print("<font color='green'>Pass</font>");
				 	 	}else{
				 	 		out.print("<font color='red'>Deny</font>");
				 	 	}	
				 	 %>
				 	</td>
				 	<td>
				 	<a href="paper_review_detail.jsp?paper_id=<%=paper_id%>">Details</a>
				 	</td>
				 	<td>
				 	<input type="button" value="Pass" onclick="pass(<%=paper_id%>)">
				 	<input type="button" value="Deny" onclick="deny(<%=paper_id%>)">
				 	</td>
				 </tr>
				 <%
				 	}
				  %>
				 <tr>
			   		<td colspan="9">
			   		<hr>
			   		</td>
			   	 </tr>
			  	 <tr>
			  		<td>
			  		<input type="checkbox" name="select_all_paper" value="All_paper" onClick="javascript:selectall()">All
			  		</td>	
			  		<td colspan="2">
			  		&nbsp;
			  		</td>	
			  		<td>
			  		<input type="button" value="Pass Selected" onClick="pass_selected()">
			  		</td>
			  		<td>
			  		<input type="button" value="Deny Selected" onClick="deny_selected()">
			  		</td>
			  		<td colspan="4">
			  		&nbsp;
			  		</td>
			  	 </tr>
				</table>
				</form>
				
				<hr>
				
				<form action="chair_decision.jsp" method="post" name="spage">
				<table width="95%" border="0" align="center">
				<tr>
					<td>
					&nbsp;
					</td>
					<td>
					<%
						sum_page = (sum_row + row -1) / row;
						if(list.size()>=1){
				 	%>
					<div align="center">
				 	<input type="button" value="First" onClick="openpage(1)"
				  	<%=page_count==1 ? "disabled" : "" %>>
				 
				 	<input type="button" value="Preivew" onClick="openpage(<%=page_count-1%>)"
				  	<%=page_count==1? "disabled" : "" %>>
				 
				 	<input type="button" value="Next" onClick="openpage(<%=page_count+1%>)"
				  	<%=page_count==sum_page? "disabled" : "" %>>
				 
				 	<input type="button" value="Last" onClick="openpage(<%=sum_page%>)"
				  	<%=page_count==sum_page? "disabled" : "" %>>
				 
				 	<input type="hidden" name="page" value="">&nbsp;
				 
				 	<font color="red" size="3"><%=page_count%></font> /
				 	<font color="red" size="3"><%=sum_page%></font>
				 
				 	</div>
				 	<%
				 	}
				  	%>
					</td>
				</tr>
				</table>
				</form>	
				</div>
			</div>
		</div>
		
		<div class="nav"></div>
			
		<div id="footer" class="footer_color border">
			<p align="center"><b>&copy;2010 LSMS-All Rights Reserved.</b></p>
			<p align="center"> <b>Powered by Shu.</b></p>
		</div>
	</div>
  </body>
</html>
